<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/base.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="${ctsCss}/table.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<%@ include file="/common/message-save1.jsp"%>
<body>

	<form id="hang-form" class="form-horizontal"
		action="${ctx}/reportTemplateCountController/saveLieCount" method="post">
		<input type="hidden" id="templateId" name="templateId" value="${templateId}" />
		<input type="hidden" id="areaTemporaryId" name="areaTemporaryId"/>
		<div>
	       				<span style="color:red">注：列计算公式需要严格按照指定方式填写，如不按指定方式填写将不会生成相应计算公式(列名必须大写)</span>
	       				<span style="color:red">填写规则：1)A列=B列+C列，对应填写为A=B+C;2)A列=B列+C列至F列之和+G列，对应填写为A=B+C~F+G</span>
	       			</div>
		<table>
			<tr class="tab_grey">
				<td width="30%">数据区域选择</td>
				<td>
					<select id="chooseDataAreaSelectId" name="chooseDataAreaSelectName" class="chooseDataAreaSelectClass" onchange="assignmentAreaId();" required></select>
				</td>
			</tr>
			<tr class="tab_grey">
				<td width="30%">公式</td>
				<td><textarea rows="3" cols="70" id="calcFormulaShow"
						name="calcFormulaShow"></textarea></td>
			</tr>
			<tr class="tab_grey">
				<td width="30%">序号</td>
				<td width="70%" colspan="3">
				<input type="text" id="orderId"
					name="orderId" value="${rptTemplateCalc.orderId }" required
					style="width: 200px" maxlength='100' /></td>
			</tr>
		</table>
		<div style="text-align: center;">
			<button type="button" class="btn btn-primary" id="saveBtn"
				onclick="add();">保存</button>
		</div>
	</form>

</body>

<script type="text/javascript">
$('#hang-form').validate();
function add() {
	$("#hang-form").submit();
}

function onloadReportTemporary(){
	var templateId = $("#templateId").val();
	$.ajax({
		url:'${ctx}/reportDesignController/queryReportAreaTemporary/'+templateId,
		type:'POST',
		cache:false,
		success:function(data){
			var treeSelectIdOptions = "";
		    $.each(data,function(idx,item){
		    	treeSelectIdOptions += "<option value='"+item.id+"'>" + item.temporaryDescribe + "</option>";
			});
		    $("#chooseDataAreaSelectId option").remove();
		    treeSelectIdFirst="<option value='0'>请选择</option>";
		    $(".chooseDataAreaSelectClass").append(treeSelectIdFirst).append(treeSelectIdOptions);
		}
	});
}

$(document).ready(function(){//初始化
	onloadReportTemporary();
});
function assignmentAreaId(){
	var chooseDataAreaSelectId = $("#chooseDataAreaSelectId").val();
	$("#areaTemporaryId").val(chooseDataAreaSelectId);
}
</script>
</html>